home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 14 / Hot Mix 14.iso / HTML / vendors / finesse / examples / sh / nastran_lsf < prev    next >
Text File  |  1996-06-27  |  7KB  |  302 lines

  1. #! /bin/sh
  2. # FINESSEAPPLICATIONKEY sKITl?iQqZZ[q
  3. #
  4. # Create simple front end for nastran jobs
  5. # ----------------------------------------
  6. # ----------------------------------------
  7. #
  8. # Use some NASTRAN Info
  9. #----------------------
  10. TMPFILE=/tmp/nast.$$
  11. NAST_VER="67"             
  12. NAST_RC="nast${NAST_VER}rc"    
  13. EXE_NAME="NAST${NAST_VER}r2"     
  14. memlower=10
  15. timellower=1
  16. memupper=1000
  17. timelupper=1000
  18.  
  19. # Finesse Initialisation
  20. # ----------------------
  21.  
  22. . ${FINESSEPATH-/usr/local/finesse}/fsshinit
  23.  
  24.  
  25. # Declare input window
  26. # --------------------
  27. yes=Yes
  28. no=No
  29.  
  30. jidname="Input File"
  31. rcfname="Jobname"
  32. sdiname="Scratch Directory"
  33.  
  34. naswin="                                      
  35.   FsWindow        -name naswin
  36.                   -title LSF-Nastran;
  37.   FsSelectionText -label '$jidname:'
  38.                   -var jid;
  39.   FsSelectionText -label '$rcfname:'
  40.                   -var rcf=$NAST_RC;
  41.  
  42.   FsSeparator -name separator;
  43.  
  44.   FsForm -name form1 -orientation horizontal;
  45.   FsForm -name form2 -parent form1;
  46.   FsList -label '$sdiname:' 
  47.          -items '/net/ws1/scr 
  48.                  /net/filesrv1/scr/scr1 
  49.                  /net/filesrv1/scr/scr2
  50.                  /net/filesrv2/scr/scr1 
  51.                  /net/filesrv2/scr/scr1'
  52.      -var sdi=/net/filesrv1/scr/scr1
  53.      -parent form2 -nvisible 4;
  54.  
  55.   FsSeparator -parent form2 -line no 
  56.               -name separator1;
  57.  
  58.   FsText   -label 'Total Memory (MB):'
  59.            -var mem=50 -parent form2 
  60.        -name text1 -packing tight;
  61.  
  62.   FsText   -label 'Time Limit (Min.)'
  63.            -var timel=50 -parent form2 
  64.        -name text2 -packing tight;
  65.  
  66.   FsSeparator -name midsep -line dashed 
  67.               -parent form1;
  68.  
  69.   FsForm -name form3 -parent form1;
  70.  
  71.   FsRadio  -label 'Delete Scratch:'
  72.        -items '$yes $no' -name radio
  73.            -var scr=$yes -parent form3;
  74.  
  75.   FsRadio  -label 'Notify when job is done:'
  76.        -items '$yes $no' -name radio
  77.            -var not=$no -parent form3;
  78.  
  79.   FsRadio  -label 'Save old files:'
  80.        -items '$yes $no' -name radio
  81.            -var old=$yes -parent form3;
  82.  
  83.   FsRadio  -label Queue -var queue=normal -name radio
  84.        -items 'normal priority' -parent form2 ;
  85.  
  86.   FsPushButton -winstat touch -fsbutton info -name infobut  
  87.     -label 'Information' -parent form3;
  88.  
  89.   FsPushButton -winstat touch -fsbutton dispsc -name infobut  
  90.     -label 'Show Finesse-Script' -parent form3  ;
  91.  
  92.   FsPushButton -winstat touch -fsbutton dispwin -name infobut  
  93.     -label 'Show Windowdefinition' -parent form3  ;
  94.  
  95.   FsPushButton -winstat touch -fsbutton dispsh -name infobut  
  96.     -label 'Display Jobscript' -parent form3 -nrows 4 ;
  97.  
  98.   FsSeparator -name separator;
  99.  
  100.   FsPushButton -winstat touch -fsbutton sub  -label 'Submit Job';
  101.   FsPushButton -winstat touch -fsbutton stat -label 'Job Status';
  102.   FsPushButton -fsbutton exit -label Exit;
  103. "
  104.  
  105. # Plausibility checks:
  106. # --------------------
  107.  
  108. # Test filenames. $1: variable; $2: name
  109. # ---------------
  110.  
  111. testname()
  112. {
  113.   if [ ! -z "$1" ] ; then  
  114.     return 0;     # correct
  115.   else
  116.     mesg="$2 missing..."
  117.     return 1;     # erroneous
  118.   fi
  119. }
  120.  
  121. # Test Memory 
  122. # $1: value; $2: lower limit; $3: upper limit
  123.  
  124. testmem()
  125. {
  126. if [ -z "$1" ] ; then 
  127.   mesg="No Memory given..."; return 1; 
  128. else
  129.   var=`expr $1 : '.*\([^0-9]\).*'`
  130.   if [ -z "$var" ] ; then  
  131.     if [ $1 -lt $2 ] ; then 
  132.      mesg="$1<$2: Memory too small..."; 
  133.      return 1; fi
  134.     if [ $1 -gt $3 ] ; then 
  135.      mesg="$1>$3: Memory too large..."; 
  136.      return 1; fi
  137.     return 0;                          
  138.   else
  139.     mesg="Bad memory value..."; return 1;     
  140.   fi
  141. fi
  142. }
  143.  
  144.  
  145. # Test Time
  146. # $1: value; $2: lower limit; $3: upper limit
  147.  
  148. testtime()
  149. {
  150. if [ -z "$1" ] ; then 
  151.   mesg="No Time Value specified ..."; return 1; 
  152. else
  153.   var=`expr $1 : '.*\([^0-9]\).*'`
  154.   if [ -z "$var" ] ; then  
  155.     if [ $1 -lt $2 ] ; then 
  156.      mesg="$1<$2: Time limit too small..."; 
  157.      return 1; fi
  158.     if [ $1 -gt $3 ] ; then 
  159.      mesg="$1>$3: Time limit too high..."; 
  160.      return 1; fi
  161.     return 0;                          
  162.   else
  163.     mesg="Bad time value..."; return 1;     
  164.   fi
  165. fi
  166. }
  167.  
  168. #
  169. #
  170. genjob()
  171. {
  172. cat << EOT > $TMPFILE
  173. #!/bin/sh
  174. i=0
  175. echo This is a Nastran simulation.
  176. echo $timel Minutes CPU time are requested.
  177. echo $mem Megabytes of memory are requested.
  178. while [ \$i -le 10000 ] ; do
  179.     i=\`expr \$i + 1\`
  180. done
  181. echo Job finished.
  182. EOT
  183. chmod 700 $TMPFILE
  184. }
  185.  
  186.  
  187.  
  188. # Begin Finesse dialog, open input window
  189. # ---------------------------------------
  190.  
  191. Fsopen "$@"                                
  192.  
  193. while :
  194. do
  195.  
  196. Fsdisplay -n naswin -w "$naswin" -m "Nastran Input"
  197.  
  198. #----------------------------------------------------------
  199. if [ "$fsbutton" = "exit" ] ; then 
  200.  Fsclose; exit 0; fi
  201.  
  202. #----------------------------------------------------------
  203. if [ "$fsbutton" = "sub" ] ; then
  204. # Check variables, on error reopen window
  205. #----------------------------------------
  206. until testname "$jid" "$jidname" &&
  207.       testname "$rcf" "$rcfname" &&
  208.       testname "$sdi" "$sdiname" &&
  209.       testmem $mem $memlower $memupper &&
  210.       testtime $timel $timellower $timelupper
  211. do
  212.   date | Fsecho -i -p beginning
  213.   Fsecho Input ERROR : $mesg
  214.   echo \\007
  215.   Fsdisplay -n naswin -m "$mesg"
  216.   if [ "$fsbutton" = "exit" ] ; then 
  217.    Fsclose; exit 0; fi
  218. done
  219. Fssave
  220. # OK, start job
  221. # -------------
  222. date | Fsecho -i -p beginning
  223. Fsecho "Input is OK. Job is generated..."
  224. genjob
  225.  
  226. #cat $TMPFILE | bsub -J $rcf -M $mem -c $timel -q $queue -R - 2>&1 | Fsecho -i
  227.  
  228. rm -f $TMPFILE
  229. fi
  230.  
  231. #----------------------------------------------------------
  232. if [ "$fsbutton" = "stat" ] ; then
  233.     date | Fsecho -i -p beginning
  234. #    bjobs 2>&1 |    Fsecho -i
  235. fi
  236.  
  237. #----------------------------------------------------------
  238. if [ "$fsbutton" = "dispsc" ] ; then
  239.     date | Fsecho -i -p beginning
  240.     Fsecho -p beginning -f $0
  241. fi
  242.  
  243. #----------------------------------------------------------
  244. if [ "$fsbutton" = "dispsh" ] ; then
  245.     date | Fsecho -i -p beginning
  246.     genjob
  247.     Fsecho -p beginning -f $TMPFILE
  248. fi
  249.  
  250. #----------------------------------------------------------
  251. if [ "$fsbutton" = "dispwin" ] ; then
  252.     Fsecho -p beginning -t '
  253.  
  254. =========================================================
  255.           FINESSE Window definition
  256. =========================================================
  257.  
  258. '"$naswin" 
  259. fi
  260.  
  261. #----------------------------------------------------------
  262. if [ "$fsbutton" = "info" ] ; then
  263.     Fsecho -p beginning -t '
  264.  
  265. =========================================================
  266.     Starting Nastran with LSF and FINESSE
  267. =========================================================
  268.  
  269. This FINESSE Window is an example for a jobstarter that
  270. can be used to start a CAE application, e.g. NASTRAN.
  271. Usually a CAE job  is generated useing all parameters,
  272. that are set by the user in the window of this jobstarter.
  273. In this demo, there is no functionality concerning  the 
  274. management of your jobflow. This window shows how simple 
  275. it is to generate a window and how to use the parameters 
  276. set by the user. 
  277.  
  278. The window is defined in the shellscript $0. The calls 
  279. fsopen, fsdisplay, fsecho, fssave and fsclose are the only
  280. FINESSE commands.  
  281.  
  282. In this demo, nastran is simulated by a generated shellscript 
  283. that consumes CPU-time. The resources memory-Limit 
  284. and CPU-limit are used when the job is started into LSF
  285. with the bsub command.
  286.  
  287. The Jobstatus can be displayed by pressing the Jobstatus 
  288. button. In this window jobcontrol is not possible. 
  289.  
  290. '
  291. fi
  292.  
  293. done
  294.  
  295. Fsclose
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.